<?php
$id = $_REQUEST['id'];

$url = urlencode("http://twittertido.com.es/tweet.php?id=$id");
$image = urlencode('http://www.twittertido.com.es/movil/img/logo_512.png');

$jsonurl = "http://nibble.li/twittertido/web/getTweet.php?id=$id";
$json = file_get_contents($jsonurl, 0, null, null);
$json_output = json_decode($json, true);
$arrays = $json_output['tweets'];
$tweet = $arrays[0];
$summary = urlencode($tweet['tweet']);

$tweet_text = $tweet['tweet'];
if (strlen($tweet_text) > 102) {
    $tweet_text = substr($tweet_text, 0, 100) . "... ";
}

$title = $tweet_text;
?>

<!DOCTYPE html> 
<html> 
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1"> 
        <title><?php print $tweet_text ?></title>
        <meta property="og:title" content="<?php print $tweet_text; ?> v&iacute;a Twittertido" />
        <meta property="og:description" content="Twittertido! Los mejores y m&aacute;s graciosos tweets en espa&ntilde;ol!" />
        <meta property="og:image" content="http://twittertido.com.es/img/logo_128.png" />
        <link rel="stylesheet"  href="//code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
    </head> 
    <body> 

        <div data-role="page">
            <div data-role="header" data-theme="d">
                <h1>Twittertido</h1>
            </div>
            <div data-role="content" data-theme="c" style="text-align: center">
                <div style="clear: both"><br /></div>
                <a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php echo $url; ?>" data-text="<?php echo "$tweet_text http://twittertido.com.es/tweet.php?id=$id"; ?>" data-via="tuittertido" data-lang="es" data-size="large">Twittear</a>
                <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
            </div>
        </div>
    </body>
</html>